package com.supper.customize.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author yutao
 * @since 2020/4/15 2:58 下午
 */
public class TestDemo {

    public static void main(String[] args) throws Exception {

        Class<Demo> demoClass = Demo.class;

        MyAnnotation annotation = demoClass.getAnnotation(MyAnnotation.class);
        System.out.println(annotation.getYutao());

        Field name = demoClass.getField("name");
        MyAnnotation fieldAnn = name.getAnnotation(MyAnnotation.class);
        System.out.println(fieldAnn.getYutao());

        Method hello = demoClass.getMethod("hello", null);
        MyAnnotation methodAnn = hello.getAnnotation(MyAnnotation.class);
        System.out.println(methodAnn.getYutao());

    }

}
